package com.ymttest.database.sqlwapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.IpChunHui;
import com.ymttest.database.model.LoginLog;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;

/************************************************************************************
 * @File name :DefaultWapper.java
 * @Author : zhouyi
 * @Date : 2015年6月1日
 * @Copyright : 洋码头
 ************************************************************************************/
public class WXToken2Wapper {
	SqlManager manage;

	public WXToken2Wapper() {
		manage = new SqlManager("wxtoken2");
	}

	/**
	 * Token（iKeyType=0）
	 * Ticket（iKeyType=1）
	 * @param type
	 * @return
	 */
	public List<Map> selectWxtokenByType(Integer type){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("type", type);
		List<Map> logs = manage.getSelectResults(
				"com.ymttest.database.mapping.WXToken2Mapper.selectWxtokenByType", params);
		manage.commit();
		return logs;
	}
	/**
	 * Token（iKeyType=0）
	 * Ticket（iKeyType=1）
	 * @param type
	 * 0-洋码头服务号，1-全球优选，2-代购神器商户端，3代购神器买家端
	 *  @param apptype
	 * @return
	 */
	public List<Map> selectNewWxtokenByType(Integer type,Integer apptype){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("type", type);
		params.put("apptype", apptype);
		List<Map> logs = manage.getSelectResults(
				"com.ymttest.database.mapping.WXToken2Mapper.selectNewWxtokenByType", params);
		manage.commit();
		return logs;
	}
	public List<Map> selectNewWxtokenByTypeAndUid(Integer type,Integer apptype,Integer userid){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("type", type);
		params.put("apptype", apptype);
		params.put("userid", userid);
		List<Map> logs = manage.getSelectResults(
				"com.ymttest.database.mapping.WXToken2Mapper.selectNewWxtokenByTypeAndUid", params);
		manage.commit();
		return logs;
	}
	/**
	 * 关闭数据库连接
	 */
	public void close() {
		manage.close();
	}

	@Override
	protected void finalize() throws Throwable {
		this.close();
		manage = null;
		super.finalize();
	}
	public static void main(String args[]){
		Logger.debug(new WXToken2Wapper().selectNewWxtokenByType(1,0));
	}
}
